/*
 *
 *      Copyright (c) 2018-2025, shenghua All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the pig4cloud.com developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: shenghua
 *
 */

package com.chen.base.module.log.config;

import com.chen.base.module.log.aspect.SysLogAop;
import com.chen.base.module.log.component.DefaultSysLogHandler;
import com.chen.base.module.log.component.SysLogHandlerInter;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @author ChenJinLong
 * @date 2023/6/25
 * <p>
 * 日志自动配置
 */
@EnableAsync
@RequiredArgsConstructor
@ConditionalOnProperty(value = "enable.syslog", matchIfMissing = true, havingValue = "true")
@Configuration(proxyBeanMethods = false)
public class SysLogAutoConfig {

	@Bean
	@ConditionalOnMissingBean(SysLogHandlerInter.class)
	public DefaultSysLogHandler defaultSysLogHandler() {
		return new DefaultSysLogHandler();
	}

	@Bean
	public SysLogAop sysLogAop() {
		return new SysLogAop();
	}

}
